#! /bin/bash

np=$1;
npstride=$2;
if  [[ $npstride != 1 ]]
then
    corenum[0]=1
    for i in `seq  $npstride $npstride $np`
    do
        corenum[$(($i/$npstride))]=$i;
        #echo ${corenum[$(($i/$npstride))]} $i
    done
else
    for i in `seq  1 $np`
    do
        corenum[$(($i-1))]=$i;
        #echo ${corenum[$(($i/$npstride))]} $i
    done
fi
total=30
a=24;
b=24;
outname="2d-25p"
for exe in $outname
do
    rm ./$exe.txt
    for index in `seq $a $b`;
    do 
    nx=$((2 ** $index))
    t=$((2 ** ($total - $index)))
    # for i in "${corenum[@]}";
    # do
    #     export OMP_NUM_THREADS=$i;../$exe/exe-$exe 1000 1000 1000 >> ./$exe.txt 
    #     echo  $i >> ./$outname.cpulist
    # done
    for i in 1 2 4;
    do
        export OMP_NUM_THREADS=$i;../$exe/exe-$exe 1000 1000 1000 >> ./$exe.txt 
        echo  $i >> ./$outname.cpulist
    done
    for i in `seq 6 2 96`;
    do
        export OMP_NUM_THREADS=$i;../$exe/exe-$exe 6000 6000 2000 >> ./$exe.txt 
        echo  $i >> ./$outname.cpulist
    done
    done
done


echo -e "np\tGStencils" > ./$outname.data.txt
cat ./$outname.txt |awk -F "= " '{print $NF}'| paste $outname.cpulist -  | awk '{print $1 "\t" $2 }' >>  ./$outname.data.txt
rm ./$outname.cpulist
rm ./$outname.txt